#include "HerzeleidPrecompiled.hxx"
#include "HerzeleidStateSwapSet.hxx"
using namespace HerzeleidRendererStatesNamespaceImpl;


InputAssemblerSwapSet::InputAssemblerSwapSet() 
{
	ClearAll();
}

Void InputAssemblerSwapSet::ReleaseAll()
{
	for ( auto &ElementRef : VertexBufferArray ) Safe_Release(ElementRef);
	Safe_Release( IndexBuffer );
	Safe_Release( InputLayout );
	ClearAll();
}

Void InputAssemblerSwapSet::ClearAll()
{
	Standard::ZeroValueArray( VertexOffsetArray, HERZELEID_VERTEX_BUFFER_NUM_SLOTS );
	Standard::ZeroValueArray( VertexStrideArray, HERZELEID_VERTEX_BUFFER_NUM_SLOTS );
	Standard::ZeroValueArray( VertexBufferArray, HERZELEID_VERTEX_BUFFER_NUM_SLOTS );
	eTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED;
	eIndexBufferFormat = DXGI_FORMAT_UNKNOWN;
	IndexBufferOffset = 0u;
	IndexBuffer = (nullptr);
	InputLayout = (nullptr);
}

OutputMergerSwapSet::OutputMergerSwapSet()
{
	ClearAll();
}

Void OutputMergerSwapSet::ReleaseAll()
{
	for ( auto &ElementRef : UnorderedAccessViewArray ) Safe_Release(ElementRef);
	for ( auto &ElementRef : RenderTargetViewArray ) Safe_Release(ElementRef);
	Safe_Release( DepthStencilState );
	Safe_Release( DepthStencilView );
	Safe_Release( BlendState );
	ClearAll();
}

Void OutputMergerSwapSet::ClearAll()
{
	Standard::ZeroValueArray( UnorderedAccessViewInitialCountArray, HERZELEID_UAV_NUM_SLOTS );
	Standard::ZeroValueArray( UnorderedAccessViewArray, HERZELEID_UAV_NUM_SLOTS );
	Standard::ZeroValueArray( RenderTargetViewArray, HERZELEID_RTV_NUM_SLOTS );
	Standard::ZeroValue( &BlendFactor );
	DepthStencilState = (nullptr);
	DepthStencilView = (nullptr);
	BlendState = (nullptr);
	SampleMask = (0ui32);
	StencilRef = (0ui32);
}

RasterizerSwapSet::RasterizerSwapSet()
{
	ClearAll();
}

Void RasterizerSwapSet::ReleaseAll()
{
	//ClearAll();
}

Void RasterizerSwapSet::ClearAll()
{
	Standard::ZeroValueArray( ViewportArray, HERZELEID_VIEWPORT_NUM_SLOTS );
	Standard::ZeroValueArray( ScissorRectArray, HERZELEID_VIEWPORT_NUM_SLOTS );
	RasterizerState = (nullptr);
}